<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
    <title>教师注册|河海大学实践课程考勤系统</title>
    <jsp:include page="head.jsp"/>
    <script>
        function refreshVerifyCode() {
            document.getElementById("vcode").src = "${pageContext.request.contextPath}/checkCodeServlet?time=" + new Date().getTime();
        }

        function check() {
            var msg = document.getElementById("msg");
            if (document.getElementById("tid").value === "") {
                msg.innerText = "工号不能为空！";
                return false;
            }
            if (document.getElementById("tname").value === "") {
                msg.innerText = "姓名不能为空！";
                return false;
            }
            if (document.getElementById("pwd").value === "") {
                msg.innerText = "密码不能为空！";
                return false;
            }
            if (document.getElementById("pwd").value !== document.getElementById("repeat_pwd").value) {
                msg.innerText = "密码不一致！";
                return false;
            }
            if (document.getElementById("verifycode").value === "") {
                msg.innerText = "验证码不能为空！";
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container">
    <jsp:include page="header.jsp"/>
    <div class="row">
        <div class="col-sm-offset-2 col-sm-8">
            <form class="form-horizontal" action="${pageContext.request.contextPath}/teacher/signup" method="post"
                  onsubmit="return check()">
                <div class="form-group">
                    <label class="col-sm-2 control-label input-lg" for="tid">工号</label>
                    <div class="col-sm-10">
                        <input id="tid" class="form-control input-lg" name="tid" type="text" maxlength="8">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label input-lg" for="tname">姓名</label>
                    <div class="col-sm-10">
                        <input id="tname" class="form-control input-lg" name="tname" type="text" maxlength="8">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label input-lg" for="pwd">密码</label>
                    <div class="col-sm-10">
                        <input id="pwd" class="form-control input-lg" name="pwd" type="password" maxlength="32">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label input-lg" for="repeat_pwd">重复密码</label>
                    <div class="col-sm-10">
                        <input id="repeat_pwd" class="form-control input-lg" name="repeat_pwd" type="password" maxlength="32">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label input-lg" for="verifycode">验证码</label>
                    <div class="col-sm-7">
                        <input id="verifycode" class="form-control input-lg" name="verifycode" type="text"
                               maxlength="4">
                    </div>
                    <div class="col-sm-3">
                        <a href="javascript:refreshVerifyCode();">
                            <img alt="验证码" id="vcode" class="img-responsive"
                                 src="${pageContext.request.contextPath}/checkCodeServlet"
                                 title="点击刷新">
                        </a>
                    </div>
                </div>
                <p id="msg" class="text-danger text-center">${requestScope.msg}</p>
                <input class="btn btn-block btn-primary btn-lg" type="submit" value="注册">
            </form>
            <a class="btn btn-block btn-primary btn-lg"
               href="${pageContext.request.contextPath}/teacher/login">已有账号登录</a>
            <br>
            <div class="row text-center">
                <strong>其他人员：</strong>
                <span>
                    <a class="btn btn-default" href="${pageContext.request.contextPath}/regist.jsp">我是学生</a>
                </span>
                <span>
                    <a class="btn btn-default" href="${pageContext.request.contextPath}/admin/login.jsp">我是管理员</a>
                </span>
            </div>
        </div>
    </div>
    <jsp:include page="footer.jsp"/>
</div>
</body>
</html>
